﻿using System;

namespace T.FAS.Runtime.ScheduleJob.Common
{
    public class ScheduleJobEngineIdentifier
    {
        private static object syncObj = new object();
        private static ScheduleJobEngineIdentifier instance = null;
        private ScheduleJobEngineIdentifier()
        { 
            InitConfig();
        }
        public static ScheduleJobEngineIdentifier GetInstance()
        {
            if (instance == null)
            {
                lock (syncObj)
                {
                    if (instance == null)
                        instance = new ScheduleJobEngineIdentifier();
                }
            }
            return instance;
        }
        public string HostID { get; private set; }

        private void InitConfig()
        {
            HostID = GetInstanceIDByAppCluster();
        }

        private string GetInstanceIDByAppCluster()
        {
            return Teld.Core.Cluster.Client.AppClusterQueryClient.Current.GetCurrentAppHostID();
        }
    }
}
